Skip to content

Conversation

@parksb
Copy link
Member

@parksb parksb commented Nov 11, 2025

Resolves #26

This PR implements a new catalog management system using catalogs.yml with hierarchical inheritance support.

The yarn catalogs apply command reads catalog definitions from catalogs.yml, resolves all inheritance, and writes them to .yarnrc.yml. The plugin options (default, validation, ignoredWorkspaces) are now read from the options field in catalogs.yml instead of .yarnrc.yml.

This PR removes custom catalog resolution logic and delegates it to Yarn's native Catalogs support (available since 4.10.0), while preserving the plugin's extended options features. The plugin no longer implements core catalog resolution hooks (reduceDependency, beforeWorkspacePacking).

catalogs.yml:

options:
  default: [stable/canary]
  validation: warn

list:
  root:
    lodash: npm:4.17.21

  stable:
    react: npm:18.0.0
    typescript: npm:5.1.0

  stable/canary:
    react: npm:18.2.0        # Overrides stable
    # typescript: npm:5.1.0  (inherited from stable)

  stable/canary/next:
    react: npm:18.3.0        # Overrides stable/canary
    # typescript: npm:5.1.0  (inherited from stable)

Apply to .yarnrc.yml:

$ yarn catalogs apply
➤ YN0000: root catalog:
➤ YN0000:   + lodash: npm:4.17.21
➤ YN0000: stable:
➤ YN0000:   + react: npm:18.0.0
➤ YN0000:   + typescript: npm:5.1.0
➤ YN0000: stable/canary:
➤ YN0000:   + react: npm:18.2.0
➤ YN0000:   + typescript: npm:5.1.0
➤ YN0000: stable/canary/next:
➤ YN0000:   + react: npm:18.3.0
➤ YN0000:   + typescript: npm:5.1.0
➤ YN0000: ✓ Applied 1 root catalog and 3 named catalog groups to .yarnrc.yml
➤ YN0000: Done in 0s 9ms

After applying, .yarnrc.yml contains:

catalog:
  lodash: npm:4.17.21

catalogs:
  stable:
    react: npm:18.0.0
    typescript: npm:5.1.0

  stable/canary:
    react: npm:18.2.0
    typescript: npm:5.1.0  # Inherited and resolved

  stable/canary/next:
    react: npm:18.3.0
    typescript: npm:5.1.0  # Inherited and resolved

The apply command has a --check option, which checks whether .yarnrc.yml needs to be updated and allows user to preview the changes. If typescript version is changed to 5.9.0 in the stable group and run the yarn catalogs apply --check command, the following output will be printed:

$ yarn catalogs apply --check
➤ YN0000: .yarnrc.yml is out of date. Run 'yarn catalogs apply' to update it.
➤ YN0000: stable:
➤ YN0000:   - typescript: npm:5.1.0
➤ YN0000:   + typescript: npm:5.9.0
➤ YN0000: stable/canary:
➤ YN0000:   - typescript: npm:5.1.0
➤ YN0000:   + typescript: npm:5.9.0
➤ YN0000: stable/canary/next:
➤ YN0000:   - typescript: npm:5.1.0
➤ YN0000:   + typescript: npm:5.9.0
➤ YN0000: Would apply 1 root catalog and 3 named catalog groups to .yarnrc.yml
➤ YN0000: Failed with errors in 0s 7ms

@parksb parksb marked this pull request as ready for review November 11, 2025 08:07
@parksb parksb requested a review from suhdonghwi November 11, 2025 08:07
Copy link
Collaborator

@suhdonghwi suhdonghwi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm! 👍

@suhdonghwi suhdonghwi merged commit 1cd5e9b into main Nov 19, 2025
1 check passed
@parksb parksb deleted the feat/delegate-to-yarn-catalogs branch November 19, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Questions about the future

3 participants